﻿using System;
using Terraria.Localization;
using Terraria.Map;

namespace Terraria.ModLoader
{
	// Token: 0x020001BA RID: 442
	public class MapLegend
	{
		// Token: 0x060011D2 RID: 4562 RVA: 0x0000EFC9 File Offset: 0x0000D1C9
		public MapLegend(int size)
		{
			this.legend = new LocalizedText[size];
		}

		// Token: 0x1700013D RID: 317
		// (get) Token: 0x060011D3 RID: 4563 RVA: 0x0000EFDD File Offset: 0x0000D1DD
		public int Length
		{
			get
			{
				return this.legend.Length;
			}
		}

		// Token: 0x060011D4 RID: 4564 RVA: 0x0000EFE7 File Offset: 0x0000D1E7
		internal void Resize(int newSize)
		{
			Array.Resize<LocalizedText>(ref this.legend, newSize);
		}

		// Token: 0x1700013E RID: 318
		public LocalizedText this[int i]
		{
			get
			{
				return this.legend[i];
			}
			set
			{
				this.legend[i] = value;
			}
		}

		// Token: 0x060011D7 RID: 4567 RVA: 0x0000F00A File Offset: 0x0000D20A
		public LocalizedText FromType(int type)
		{
			return this[MapHelper.TileToLookup(type, 0)];
		}

		// Token: 0x060011D8 RID: 4568 RVA: 0x0040B96C File Offset: 0x00409B6C
		public string FromTile(MapTile mapTile, int x, int y)
		{
			string text = this.legend[(int)mapTile.Type].Value;
			if (MapLoader.nameFuncs.ContainsKey(mapTile.Type))
			{
				text = MapLoader.nameFuncs[mapTile.Type](text, x, y);
			}
			return text;
		}

		// Token: 0x040013F4 RID: 5108
		private LocalizedText[] legend;
	}
}
